import BaseModule from './app/base-module'

const BridgeRequestEvent = {
  /**
   * 示例参考：bridge-device-event-mock.json
   * 示例记录：01-27
   *
   * @returns {Promise<null extends ShallowRef<infer V> ? V : (null extends Ref<infer V> ? UnwrapRefSimple<V> : UnwrapRefSimple<null>)>|Promise<unknown>}
   */
  data(
    url,
    params = {},
    method = 'POST',
    options = { headers: {}, timeout: 60, needHUD: false }
  ) {
    const command = {
      transactionId: url,
      method,
      params,
      options,
    }
    return BaseModule.fireEventForAsync('request', command)
  }
}

export default BridgeRequestEvent;
